package com.bw.controller;

import com.bw.bean.Vo;
import com.bw.service.VoService;
import com.sugar.SugarUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@RestController
public class VoController {
    //控制器中依赖注入正确
    @Autowired
    VoService voService;
    //与前端交互方法正确
    //1.1按照第二大类交易额展示饼状图
    @RequestMapping("list1")
    public Map list1(){
        List<Vo> list = voService.getlist1();
        return SugarUtil.getPieData(list);
    }
    //1.2按品牌交易额 展示柱状图
    @RequestMapping("list2")
    public Map list2(){
        List<Vo> list = voService.getlist2();
        return SugarUtil.getBarData(list);
    }
    //1.3总成交金额的 数字翻牌展示
    @RequestMapping("list3")
    public Map list3(){
        Double val = voService.getlist3();
        return SugarUtil.getFlipNumberData(val);
    }
    //1.4按SPU 分组，订单金额  轮播表格展示
    @RequestMapping("list4")
    public Map list4(){
        List list1 = new ArrayList();
        list1.add("品牌名称");
        list1.add("总金额");
        List<Vo> list = voService.getlist4();
        return SugarUtil.getTablePlayData(list1,list);
    }
}
